# 定义颜色变量, 还记得吧, \033、\e和\E是等价的
RED='\E[1;31m'       # 红
GREEN='\E[1;32m'    # 绿
YELOW='\E[1;33m'    # 黄
BLUE='\E[1;34m'     # 蓝
PINK='\E[1;35m'     # 粉红
RES='\E[0m'          # 清除颜色

echo -e  "${GREEN}step1/10 开始发布后台${RES}"
cd make-money
echo -e  "${GREEN}step2/10 pull代码${RES}"
git fetch --all
git reset --hard origin/master
git pull
git branch
git log -1
echo -e  "${GREEN}step3/10 构建代码${RES}"
mvn clean package -Dmaven.test.skip=true
echo -e  "${GREEN}step4/10 start 制作镜像${RES}"
docker build -f Dockerfile -t xiohuchi/make-money:latest .
echo -e  "${GREEN}step5/10 start 推送镜像${RES}"
docker push ccr.ccs.tencentyun.com/xiohuchi/make-money:latest
echo -e  "${GREEN}step6/10 start 拉取镜像${RES}"
docker pull ccr.ccs.tencentyun.com/xiohuchi/make-money:latest
echo -e  "${GREEN}step7/10 start 停止容器${RES}"
docker stop make-money
echo -e  "${GREEN}step8/10 start 删除容器${RES}"
docker rm make-money
echo -e  "${GREEN}step9/10 start 创建容器${RES}"
docker run -itd --network=host -p 8088:8088 -e server_port=8088 -e datasource_username='root' -e datasource_password='kvgkiXkxM7npW8z4' -e redis_password='meMBkwHMq4fx6w3D' --name make-money ccr.ccs.tencentyun.com/xiohuchi/make-money:latest
echo -e  "${GREEN}step10/10 开始启动容器...${RES}"
docker logs -f make-money